#!/bin/bash
## RPJ 27.8.2026
## simple mo to po file converter
# 
# 

#TEXTDOMAINDIR=/usr/share/locale
#TEXTDOMAIN=mo2po

yad --center --width=500 --height=30 --text-align=center --title=$"Do you want to make a po file from a mo file?" --text=$"Do you want to make a po file from a mo file?"
if [ $? = 0 ];
then
yad --width=300 --height=30 --text-align=center --text=$"Choose mo file" --title=$"Choose mo file" --button=OK:0
MO=`cd /usr/share/locale && yad --file --width=1000  yad --button=OK:0 --text=$"Choose mo file" --title=$"Choose mo file"` 
ls $MO > /tmp/mopo0.txt

awk -F "/" '{print $NF}' /tmp/mopo0.txt > /tmp/mopo00.txt

awk -v FS='.' '{print $1}' /tmp/mopo00.txt > /tmp/mopo.txt

msgunfmt $MO > $(cat /tmp/mopo.txt).po
sleep 1
yad --center --width=500 --height=30 --text-align=center --button=OK:0 --title=$"$(cat /tmp/mopo.txt) is converted as $(cat /tmp/mopo.txt).po file " --text=$"$(cat /tmp/mopo.txt) is converted as po-file"  
else exit 0
fi

sleep 5

cd /tmp && rm mopo0.txt mopo00.txt mopo.txt
